<?php
// $Id$

require_once($WSC->get_site_inc_dir().'modules/tangra_cms/classes/vpt/vpage_abs_dbc.class.php');

class VPage_Category_Content_DBC extends VPage_Abs_DBC {
	private $category;

	public function save(DB_Connection $dbc, $current_user_id = 0) {
		$ret = false;

		if ($this->get_id()) {
			$vpage = new TCMS_VPage_DBC();
			if ($vpage->load_by_id($dbc, $this->get_id())) {
				$this->save_system_attribute($dbc, $vpage->get_id(), $vpage->get_template(), 'category_hid', $this->get_category());

				TCMS_VPage_DBC::update_last_modified($dbc, $vpage->get_id(), $current_user_id);
			}

			$ret = true;
		}


		return $ret;
	}


	public function load_by_id(DB_Connection $dbc, $id) {
		tangra_if_not_int_throw_e($id);

		$category = $this->load_system_attribute($dbc, $id, 'category_hid');
		if ($category) {
			$this->set_category($category->get_value());
		}

		$this->set_vpage_id($id);

		return $id;
	}


	public function set_category($category) {
		$this->category = $category;
	}


	public function get_category() {
		return $this->category;
	}
}